﻿@{
    ViewBag.Title = "固定资产编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style>
    body {
        margin: 0;
    }

    .style11 {
        height: 32px;
        line-height: 32px;
        text-align: left;
        vertical-align: middle;
        /*font-weight: bold;*/
    }

    textarea {
        margin: 0;
        border: 1px solid #95B8E7;
        border-radius: 5px;
    }
</style>
<script src="~/Content/layer-v3.1.1/layer/layer.js"></script>
<script>
    $(function () {
        //加载combobox列表
        loadComboboxData();
        //页面数据初始化
        pageInit();

        //监控保存/新增按钮的点击事件
        $("#btnSave").on("click", function () {
            submitForm();
        })

        ////监控清空按钮的点击事件
        //$("#btnClear").on("click", function () {
        //    clearForm();
        //})

    })


    //函数：页面数据初始化
    function pageInit() {
        //获取页面传递参数
        var state = '@ViewBag.State';
        var code = '@ViewBag.Code';

        //若为新增页
        if (state == "new") {
            //更改保存按钮文本
            $("#btnSave").linkbutton({
                text: "新增"
            });
        }
            //若为编辑页
        else if (state == "edit") {
            $.ajax({
                url: '@Url.Content("~/FixedAssets/FixedAssetsMaterial/GetEditPageData")' + "?timestamp=" + new Date().getTime(), ///url添加时间戳后缀,解决IE浏览器中Get请求方式有缓存问题
                data: {
                    Code: code
                },
                success: function (data) {
                    if (!data) {
                        return false;
                    }
                    console.log(data);
                    //赋值
                    $("#txt_BianMa").val(data.BianMa);
                    $("#txt_MingCheng").textbox("setValue", data.ZiChanMingCheng);        //固定资产名称
                    $("#txt_XuLieHao").textbox("setValue", data.ZhuJiXuLieHao);           //主机序列号
                    $("#txt_AssetCode").textbox("setValue", data.GuDingZiChanBianMa);     //固定资产编码
                    $("#txt_PinPai").textbox("setValue", data.PinPai);                    //品牌
                    $("#txt_XingHao").textbox("setValue", data.XingHao);                  //型号
                    $("#txt_GuiGe").textbox("setValue", data.GuiGe);                      //规格
                    $("#txt_DanWei").textbox("setValue", data.DanWei);                    //单位
                    $("#txt_ShuLiang").textbox("setValue", data.ShuLiang);                //数量
                    $("#txt_FaPiaoHaoMa").textbox("setValue", data.FaPiaoHaoMa);          //发票号码
                    $("#txt_DanJia").numberbox("setValue", data.DanJia);                    //单价
                    $("#txt_CunFangDian").textbox("setValue", data.DangQianCunFangDian);  //当前存放点
                    $("#txt_ChePaiHaoMa").textbox("setValue", data.DangQianChePaiHaoMa);  //当前车辆号码
                    $("#txt_GuanLiBuMen").textbox("setValue", data.ZiChanGuanLiBuMen);    //资产管理部门
                    $("#txt_GuanLiRen").textbox("setValue", data.ZiChanGuanLiRen);        //资产管理人
                    $("#txt_BeiZhu").textbox("setValue", data.BeiZhu);                    //备注

                    //$("#cmb_AssetType").combotree("setValue", data.LeiXingBianMa);        //资产类型编码
                    //$("#cmb_Storage").combotree("setValue", data.DangQianCangKuBianMa);   //当前仓库编码
                    $("#cmb_AssetType").combotree({
                        onLoadSuccess: function () {
                            $("#cmb_AssetType").combotree("setValue", data.LeiXingBianMa);
                        }
                    });        //资产类型编码
                    $("#cmb_Storage").combotree({
                        onLoadSuccess: function () {
                            $("#cmb_Storage").combotree("setValue", data.DangQianCangKuBianMa);
                        }
                    });   //当前仓库编码
                    $("#cmb_ShiFouBaoFei").combobox("setValue", data.ShiFouBaoFei ? "True" : "False");       //是否报废

                    $("#dt_GouJianRiQi").datebox("setValue", $.formatDate(data.GouJianRiQi));           //购建日期
                    $("#dt_RuKuRiQi").datebox("setValue", $.formatDate(data.RuKuRiQi));                 //入库日期


                }
            });
        }
    }

    //加载easyui combobox选择列表数据
    function loadComboboxData() {
        //固定资产分类
        $('#cmb_AssetType').combotree({
            url: '@Url.Content("~/FixedAssets/FixedAssetsDictionary/GetActiveAssetsTypeTree")',
            prompt: '--请选择--',
        });

        //使用部门/分站---当前仓库
        $('#cmb_Storage').combotree({
            url: '@Url.Content("~/FixedAssets/FixedAssetsStorage/GetActiveAssetsStorageTree")',
            prompt: '--请选择--',
        });

        //是否报废
        $("#cmb_ShiFouBaoFei").combobox({
            editable: false,
            prompt: '--请选择--',
            panelHeight: 120,
            data: [{
                value: 'True',
                text: '是'
            }, {
                value: 'False',
                text: '否',
                selected: true
            }]
        });
    }

    //函数：提交表单数据
    function submitForm() {
        var state = '@ViewBag.State'; //获取当前页state，作为额外参数提交
        $('#InfoForm').form('submit', {
            url: '@Url.Content("~/FixedAssets/FixedAssetsMaterial/SaveEditPageData")',
            queryParams: {
                state: state
            },
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (data) {
                var data = JSON.parse(data);
                if (data == "更新成功") {
                    parent.hideLayerPage();
                }
                else if (data == "新增成功")
                {
                    parent.reload();
                }
                else {
                    layer.alert(data, function (index) {
                        layer.close(index);
                    })
                }
            }
        });
    }

    ////函数：清除表单数据
    //function clearForm() {
    //    layer.confirm("确认要清空表单输入嘛？", {
    //        btn: ['确定', '取消'] //按钮
    //    }, function (index) {
    //        layer.close(index);
    //        $("#InfoForm").form("clear"); //调用easyui form clear方法
    //
    //        //清空表单输入时重设默认值
    //        //...
    //    });
    //}
</script>
<div id="InfoFormBox" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div style="padding:10px 40px 20px 40px">
        <p class="style11">
            <img align="bottom" src="~/Images/main/icon018a1.gif" width="20" height="20" style="vertical-align: middle;" />
            固定资产信息
        </p>
        <form id="InfoForm" method="post" enctype="multipart/form-data" name="StationForm">
            <table cellpadding="5" style="width:100%; height:100%; margin-top:10px; margin-bottom:10px;" cellspacing="0">
                <tr>
                    <td colspan="4">
                        <input type="hidden" name="BianMa" id="txt_BianMa" />
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle" style="width:15%">资产名称：</td>
                    <td align="left" valign="middle" style="width:35%">
                        <input class="easyui-textbox" type="text" name="ZiChanMingCheng" id="txt_MingCheng" data-options="required:true" style="width:200px;">
                    </td>
                    <td align="left" valign="middle" style="width:15%">主机序列号：</td>
                    <td align="left" valign="middle" style="width:35%">
                        <input class="easyui-textbox" type="text" name="ZhuJiXuLieHao" id="txt_XuLieHao" style="width:200px;">
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle">固定资产编码：</td>
                    <td align="left" valign="middle" colspan="3">
                        <input class="easyui-textbox" type="text" name="GuDingZiChanBianMa" id="txt_AssetCode" style="width:200px;">
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle">类别：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-combotree" type="text" name="LeiXingBianMa" id="cmb_AssetType" data-options="required:true" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">品牌：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="PinPai" id="txt_PinPai" style="width:200px;">
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle">型号：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="XingHao" id="txt_XingHao" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">规格：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="GuiGe" id="txt_GuiGe" style="width:200px;">
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle">单位：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="DanWei" id="txt_DanWei" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">数量：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="ShuLiang" id="txt_ShuLiang" style="width:200px;">
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle">发票号码：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="FaPiaoHaoMa" id="txt_FaPiaoHaoMa" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">单价：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-numberbox" name="DanJia" id="txt_DanJia" data-options="min:0,precision:2" style="width:200px;">
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle">购建日期：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-datebox" type="text" name="GouJianRiQi" id="dt_GouJianRiQi" data-options="required:true" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">入库日期：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-datebox" type="text" name="RuKuRiQi" id="dt_RuKuRiQi" data-options="required:true" style="width:200px;">
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle">使用部门/分站：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-combobox" type="text" name="DangQianCangKuBianMa" id="cmb_Storage" data-options="required:true" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">是否报废：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-combobox" type="text" name="ShiFouBaoFei" id="cmb_ShiFouBaoFei" data-options="required:true,readonly:true" style="width:200px;">
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle">当前存放点：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="DangQianCunFangDian" id="txt_CunFangDian" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">当前车牌号码：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="DangQianChePaiHaoMa" id="txt_ChePaiHaoMa" style="width:200px;">
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="middle">资产管理部门：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="ZiChanGuanLiBuMen" id="txt_GuanLiBuMen" style="width:200px;">
                    </td>
                    <td align="left" valign="middle">资产管理人：</td>
                    <td align="left" valign="middle">
                        <input class="easyui-textbox" type="text" name="ZiChanGuanLiRen" id="txt_GuanLiRen" style="width:200px;">
                    </td>
                </tr>
                <tr style="background-color: #F0F0F0;">
                    <td align="left" valign="middle">备注：</td>
                    <td align="left" valign="middle" colspan="3">
                        <input class="easyui-textbox" type="text" name="BeiZhu" id="txt_BeiZhu" data-options="multiline:true,validType:'length[0,200]'" style="width:80%;height:50px;">
                        <span style="font-size:13px;color:#999;">不超过200字</span>
                    </td>
                </tr>
            </table>
        </form>
        <div style="text-align:center;padding:5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" id="btnSave">保存</a>
            @*<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-clear'" id="btnClear">清空</a>*@
        </div>
    </div>
</div>

